package com.longkey.workflow.client.model
{
	public class TemplateModel
	{
		private var _templateId:Number;
		private var _templateName:String;
		
		private var _templateKey:String;
		
		[ArrayElementType("com.longkey.workflow.client.model.NodeModel")]
		private var _nodes:Array;
		
		[ArrayElementType("com.longkey.workflow.client.model.LinkModel")]
		private var _links:Array;
		
		public function TemplateModel(data:Object = null)
		{
			this._nodes = new Array();
			this._links = new Array();
			if(data != null){
				init(data);
			}
		}
		
		public function init(data:Object):void{
			this._templateId = data["templateId"] as Number;
			this._templateName = data["templateName"] as String;
			this._templateKey = data["templateKey"] as String;
			var ary:Array = data["nodes"] as Array;
			for(var i:int = 0; i < ary.length; i ++){
				var one:Object = ary[i];
				var node:NodeModel = new NodeModel(one);
				if(node.nodeKey != null){
					this._nodes.push(node);
				}
			}
			ary = data["links"] as Array;
			for(i = 0; i < ary.length; i++){
				one = ary[i];
				var link:LinkModel = new LinkModel(one);
				if(link.linkKey != null){
					this._links.push(link);
				}
			}
		}

		public function get templateId():Number{
			return this._templateId;
		}
		
		public function set templateId(id:Number):void{
			this._templateId = id;
		}
		
		public function get templateKey():String{
			return this._templateKey;
		}
		
		public function set templateKey(key:String):void{
			this._templateKey = key;
		}
		
		public function get templateName():String{
			return this._templateName;
		}
		
		public function set templateName(name:String):void{
			this._templateName = name;
		}
	}
}